//
//  KFDMyEventsViewCellComposer.m
//  KFD
//
//  Created by JIRENTIANXIANG on 7/7/15.
//  Copyright © 2015 kfd. All rights reserved.
//

#import "KFDMyActivitiesViewCellComposer.h"
#import "ui_config.h"
#import "NSDate+format.h"
#import "JRTXLinearLayout.h"
#import "KFDStartEndTimeView.h"

@interface KFDMyActivitiesViewCellComposer ()

@property (strong,nonatomic) UILabel* titleLabel;
@property (strong,nonatomic) KFDStartEndTimeView* startEndTimeView;

@end

@implementation KFDMyActivitiesViewCellComposer

-(instancetype)init
{
    if (self=[super init]) {
        _view=[[UIView alloc] init];
        [self setupTitleLabel];
        [self setupStartEndTimeView];
    }
    return self;
}

-(CGFloat)layout
{
    JRTXLinearLayout* layout=[[JRTXLinearLayout alloc] initWithFrame:CGRectMake(20, 0, SCREEN_WIDTH-20, 0)];
    [layout appendBlankLineWithHeight:15];
    [layout appendLabel:self.titleLabel widthLimit:SCREEN_WIDTH-20-20 alignment:JRTXLinearLayoutAlignmentLeft];
    [layout appendBlankLineWithHeight:5];
    [layout appendView:self.startEndTimeView alignment:JRTXLinearLayoutAlignmentLeft];
    [self.view addSubview:layout.view];
    return layout.view.frame.size.height;
}

-(void)setActivity:(KFDPreferentialActivity *)activity
{
    _activity=activity;
    self.titleLabel.text=activity.title;
    self.startEndTimeView.startTimeLabel.text=[NSString stringWithFormat:@"参与时间 : %@",activity.starttime.year_month_day];
    self.startEndTimeView.endTimeLabel.text=[NSString stringWithFormat:@"结束时间 : %@",activity.endtime.year_month_day];
    self.startEndTimeView.frame=CGRectMake(0, 0, SCREEN_WIDTH-20-20, 24);
}

-(void)setupTitleLabel
{
    self.titleLabel=[[UILabel alloc] init];
    self.titleLabel.textColor=KFD_TEXT_DARK_GRAY;
    self.titleLabel.font=[UIFont systemFontOfSize:14];
}

-(void)setupStartEndTimeView
{
    self.startEndTimeView=[[NSBundle mainBundle] loadNibNamed:@"KFDStartEndTimeView" owner:nil options:nil].firstObject;
}

@end
